using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
using LastoRevival.Service.Contracts.Models;

namespace LastoRevival.Service.Implementations.Data.Sql.Converters
{
	public class PreviewForumModelCreator
	{
		public PreviewForumModel Create(DataRow forumRow)
		{
			var forum = new PreviewForumModel
				{
					Description = string.Format("{0}", forumRow["description"]),
					ForumID = (int)forumRow["forumid"],
					SortOrder = (int)forumRow["indexorder"],
					ThreadCount = (int)forumRow["threads"],
					MessageCount = (int)forumRow["messages"],
					Title = string.Format("{0}", forumRow["title"]),

				};
			
			return forum;
		}

		public IEnumerable<PreviewForumModel> Create(IEnumerable<DataRow> forumRows)
		{
			var forums = new List<PreviewForumModel>();

			foreach (var row in forumRows)
			{
				forums.Add(Create(row));
			}

			return forums;
		}
	}
}